package com.gonsin.gnews.annotations.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@ApiModel("统一返回格式")
@Data
public class GNewsResponseResult<T> {

    @ApiModelProperty(value = "返回码", example = "200")
    private Integer state = 200;//响应状态码

    @ApiModelProperty("响应信息")
    private String message;//响应信息

    @ApiModelProperty("相应数据")
    private T data;//响应数据

    public static <D> GNewsResponseResult<D> result(D data) {
        GNewsResponseResult responseResult = new GNewsResponseResult();
        responseResult.state = 200;
        responseResult.message = "";
        responseResult.setData(data);
        return responseResult;
    }


    public static GNewsResponseResult simpleResult() {
        GNewsResponseResult result = new GNewsResponseResult();
        result.setState(200);
        return result;
    }

}
